import { AxiosResponse } from "axios"
import service from "/@/utils/request"
import { LoginUser } from "/@/_types/sys/user"
import { SYSTEM_CONFIG } from '/@/config/system'
import { SysConfig } from "/@/_types/sys/sysconfig"
// const appId = "wms"

/**
 * 登录接口
 * @param loginUser 登录用户
 * @returns 
 */
export function login(loginUser: LoginUser) {
    const data = {
        appId: SYSTEM_CONFIG.appId,
        client_id: SYSTEM_CONFIG.appId,
        client_secret: "password",
        grant_type: "password",
        password: loginUser.password,
        username: loginUser.account
    }
    return service.post(SYSTEM_CONFIG.tokenUrl, data)
}

/**
 * 获取拾贝云用户信息
 */
export function getUser(): Promise<AxiosResponse<any>> {
    let url = "/rest/user"
    return service.get(url)
}

/**
 * 
 * @returns 获取系统配置信息
 */
export function getSysConfig(): Promise<AxiosResponse<SysConfig>> {
    return service.post("/rest/getSysConfig", { appId: SYSTEM_CONFIG.appId })
}